jQuery(function($) {
        String.prototype.toAlias = function() {
            var str = this;
            str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g,"a");
            str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g,"e");
            str = str.replace(/ì|í|ị|ỉ|ĩ/g,"i");
            str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g,"o");
            str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g,"u");
            str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g,"y");
            str = str.replace(/đ/g,"d");

            str = str.replace(/À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ/g,"A");
            str = str.replace(/È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ/g,"E");
            str = str.replace(/Ì|Í|Ị|Ỉ|Ĩ/g,"I");
            str = str.replace(/Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ/g,"O");
            str = str.replace(/Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ/g,"U");
            str = str.replace(/Ỳ|Ý|Ỵ|Ỷ|Ỹ/g,"Y");
            str = str.replace(/Đ/g,"D");

            // remove domain extends
            str = str.replace(/\.+([\w-]{2,4})?/g," ");
            str = str.replace(/!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.| |\-|\:|\;|\"|\&|\#|\[|\]|~|$|_/g," ");
            /* tìm và thay thế các kí tự đặc biệt va khoang trang trong chuỗi sang kí tự khoang trang */
            str = str.replace(/-+-/g," "); //thay thế 2- thành khoang trang
            str = str.replace(/\s+\s/g," "); //thay thế 2 khoang trang thành 1
            str = str.replace(/^\-+|\-+$/g,"");
            str = str.replace(/^\s+|\s+$/g,"");
            //cắt bỏ ký tự -, khoang trang ở đầu và cuối chuỗi
            return str;
        };

        String.prototype.replaceAll = function(
            strTarget, // The substring you want to replace
            strSubString // The string you want to replace in.
        ){
            var strText = this;
            var intIndexOfMatch = strText.indexOf( strTarget );

            // Keep looping while an instance of the target string
            // still exists in the string.
            while (intIndexOfMatch != -1){
                // Relace out the current instance.
                strText = strText.replace( strTarget, strSubString )

                // Get the index of any next matching substring.
                intIndexOfMatch = strText.indexOf( strTarget );
            }

            // Return the updated string with ALL the target strings
            // replaced out with the new substring.
            return( strText );
        };

});